package com.hyt.it.ogt.kq.service.bm.service.impl;

import java.util.List;
import java.util.Optional;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.google.common.collect.Lists;
import com.hyt.it.ogt.kq.service.bm.feign.tps.TpsClient;
import com.hyt.it.ogt.kq.service.bm.feign.tps.model.WeChatMiniAppConfig;
import com.hyt.it.ogt.kq.service.bm.service.IWeChatService;

import lombok.extern.slf4j.Slf4j;

/**
 * @program: it-ogt-bm
 * @description: 微信操作
 * @author: Yang HuanKun
 * @create: 2022-01-20 14:53
 **/
@Slf4j
@Service
public class WeChatServiceImpl implements IWeChatService {

    @Value("${tps.bmapplet.officeId}")
    private String officeId;

    @Value("${tps.bmapplet.suppliertype}")
    private String supplierType;

    @Resource
    private TpsClient tpsClient;

    @Override
    public List<String> listNotifyTemplates() {
        return Optional.ofNullable(tpsClient.getWxConfig(officeId, supplierType))
                .map(WeChatMiniAppConfig::getExamArrangeTemplateId)
                .map(Lists::newArrayList)
                .orElse(Lists.newArrayList());
    }
}
